package com.xjoyt.pay.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

 
public class ToFormString {
	public static String  action="weixin://wap/pay";
 
	
	
	public static String buildRequest(Map<String, String> sParaTemp,
			String strMethod, String strButtonName) throws Exception {
	 
		List<String> keys = new ArrayList<String>(sParaTemp.keySet());

		StringBuffer sbHtml = new StringBuffer();

		sbHtml.append("<form id=\"weixinwappay\" name=\"weixinwappay\" action=\""
				+ action
				 
				+ "\" method=\"" + strMethod + "\">");

		for (int i = 0; i < keys.size(); i++) {
			String name = (String) keys.get(i);
			String value = (String) sParaTemp.get(name);

			sbHtml.append("<input type=\"hidden\" name=\"" + name
					+ "\" value=\"" + value + "\"/>");
		}

		// submi
		sbHtml.append("<input type=\"submit\" value=\"" + strButtonName
				+ "\" style=\"display:none;\"></form>");
		sbHtml.append("<script>document.forms['weixinwappay'].submit();</script>");
		 
		return sbHtml.toString();
	}
}
